Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Reading env file when running project locally without docker #29471

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

hirensoni913
Copy link

SUMMARY

Imported load_dotenv in config.py to read the .env file

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

TESTING INSTRUCTIONS

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot bot added the install:config Installation - Configuration settings label Jul 3, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Congrats on making your first PR and thank you for contributing to Superset! 🎉 ❤️

We hope to see you in our Slack community too! Not signed up? Use our Slack App to self-register.

@rusackas rusackas changed the title Fix: Reading env file when running project locally without docker fix: Reading env file when running project locally without docker Jul 3, 2024
Copy link
Member

@rusackas rusackas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but pinging @mistercrunch in case he knows of some intricacy I don't :) Thanks for opening this!

Copy link

codecov bot commented Jul 3, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 83.66%. Comparing base (76d897e) to head (1d9fda8).
Report is 414 commits behind head on master.

Files Patch % Lines
superset/config.py 80.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master   #29471       +/-   ##
===========================================
+ Coverage   60.48%   83.66%   +23.18%     
===========================================
  Files        1931      521     -1410     
  Lines       76236    37494    -38742     
  Branches     8568        0     -8568     
===========================================
- Hits        46114    31371    -14743     
+ Misses      28017     6123    -21894     
+ Partials     2105        0     -2105     
Flag Coverage Δ
hive 49.06% <80.00%> (-0.11%) ⬇️
javascript ?
postgres 77.11% <80.00%> (?)
presto 53.67% <80.00%> (-0.13%) ⬇️
python 83.66% <80.00%> (+20.18%) ⬆️
sqlite 76.58% <80.00%> (?)
unit 59.64% <80.00%> (+2.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@rusackas
Copy link
Member

rusackas commented Jul 3, 2024

Looks like you'll need to run the pre-commit hook to make the linters happy.

superset/config.py Outdated Show resolved Hide resolved
Copy link
Member

@mistercrunch mistercrunch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this potentially be a breaking change in some environments?

I checked that traditionally-set env vars take precedence over .env files here, but there may be a small risk of envrionments where:

  1. a [previously unused] .env file exists - maybe some service template at some companies lay a default .env file for all services
  2. .env file happens to set something that's not desired / causes a change of behavior

Another potential issue would be around docker-compose and the .env that already exist in the docker/ folder, and just want to make sure that this shouldn't be a problem there either. I can't think of anything but could see edge cases there.

Given issues are super unlikely, I'd like to push this forward, but would like to first:

  • add a note in UPDATING.md giving a heads-up to people performing upgrades. Typically they would know whether this might create a change of behavior in their env
  • add a note in our docs, letting users know that we support .env files

More generally it would be great for our config system to support more env vars, especially for simple / str parameters, maybe for an approved list of parameter and with a clear prefix, as in SUPERSET__SQLALCHEMY_EXAMPLES_URI. I think this should be a matter of creating a list of params that support this, and for-loop over it while checking for env vars fitting the pattern. + maybe a bit of smart casting to also support boolean, int, maybe even json if we were feeling fancy

@rusackas rusackas added the review:checkpoint Last PR reviewed during the daily review standup label Jul 3, 2024
@pull-request-size pull-request-size bot added size/M and removed size/XS labels Jul 4, 2024
@michael-s-molina michael-s-molina removed the review:checkpoint Last PR reviewed during the daily review standup label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
install:config Installation - Configuration settings size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants